<% layout('/layouts/default.html', {title: '广告代理商管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(adAgent.isNewRecord ? '新增广告代理商' : '编辑广告代理商')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${adAgent}" action="${ctx}/ad/adAgent/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="id"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('代理商账户')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<% if(adAgent.id != null){ %>
								<#form:input path="account" maxlength="200" class="form-control required" readonly="true"/>
							<% } %>
							<% if(adAgent.id == null){ %>
								<#form:input path="account" minlength="4" maxlength="200"  autocomplete="off"
									class="form-control required userName"
									remote="${ctx}/ad/adAgent/checkAccount?oldAccount=${adAgent.account}"
									data-msg-remote="${text('代理商账户已存在')}"/>
							<% } %>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('账户密码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="password" maxlength="255" class="form-control required" type="text" autocomplete="off"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('账户邮箱')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="email" maxlength="255" class="form-control required email"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('行业分类')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect id="industryCode" title="${text('行业分类选择')}"
									path="industryCode.industryCode" labelPath="industryCode.industryName"
									url="${ctx}/ad/adIndustryType/treeData"
									class="" allowClear="true" canSelectParent="true" canSelectRoot="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('公司名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="companyName" maxlength="200" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('联系人')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="contact" maxlength="10" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('联系电话')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="mobile" maxlength="20" class="form-control"/>
							</div>
						</div>
					</div>
					<% if(isAgent == -1){ %>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('上级代理商')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8"> 
							    <#form:treeselect id="pAgent" title="${text('代理商选择')}"
									name="pAgent.id" value="${adAgent.pAgent.id!}" 
									labelName="pAgent.account" labelValue="${adAgent.pAgent.account!}"
									url="${ctx}/ad/adAgent/treeData?curId=${adAgent.id}"
									class="" allowClear="true" canSelectParent="true" canSelectRoot="true"/>
							</div>
						</div>
					</div>
				<% } %>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('公司官网')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="companyWebsite" maxlength="255" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('营业执照')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadLicense" bizKey="${adAgent.id}" bizType="adAgent_license"
									uploadType="all" class="" readonly="false"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('ICP证书')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadIcp" bizKey="${adAgent.id}" bizType="adAgent_icp"
									uploadType="all" class="" readonly="false"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('其他资质证书')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadOtherLicense" bizKey="${adAgent.id}" bizType="adAgent_otherLicense"
									uploadType="all" class="" readonly="false"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('ad:adAgent:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>